package com.boboPlanet.user.fallback;

import com.boboPlanet.comm.entity.po.SysDictConfigPO;
import com.boboPlanet.comm.enums.FeignErrorEnum;
import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.user.feignApi.BaseDictConfigApi;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/16
 **/
@Slf4j
@Component
public class BaseDictConfigFallbackImpl implements FallbackFactory<BaseDictConfigApi> {

    @Override
    public BaseDictConfigApi create(Throwable cause) {
        return new BaseDictConfigApi() {
            @Override
            public ResponseResult<SysDictConfigPO> getOneDictConfigByCode(String code) {
                log.error("fallback method is: {} ,param is: {} , exception is: {}, errMsg is: {}","getOneDictConfigByCode",code,cause,cause.getMessage());
                return ResponseResult.error(FeignErrorEnum.FEIGN_GET_CONFIG_FAIL,null);
            }

        };
    }
}
